<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>勘察设计业绩统计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/templates/act/process-xl.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form searchForm" action=""style="padding-left: 20px;">
    申报时间:
    <div class="layui-input-inline" style="width: 150px;">
        <input type="text" name="" class="layui-input timeSelectBox" autocomplete="off" placeholder="yyyy-MM-dd">
    </div>
    至
    <div class="layui-input-inline" style="width: 150px;">
        <input type="text" name="" class="layui-input timeSelectBox" autocomplete="off" placeholder="yyyy-MM-dd">
    </div>
    <button class="layui-btn" lay-submit lay-filter="formDemo">查询</button>
    <button class="layui-btn" lay-submit lay-filter="formClear">导出</button>
</form>
<table class="layui-hide" id="dataList" lay-filter="dataList"></table>
<script type="text/javascript" src="/lib/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<script>
    var configureCom = {};
    layui.use(['jquery', 'configureCom', 'configure', 'sessionFun', 'table', 'matchDict'], function () {
        var $ = layui.jquery;
        var configure = layui.configure;
        var table = layui.table;
        var sessionFun = layui.sessionFun;
        var matchDict = layui.matchDict;
        configureCom = layui.configureCom;
        var iframeId = configureCom.GetQueryString('iframeId');
        var cols = [[
            {field: 'orgName', title: '单位名称'},
            {field: 'prjCount', title: '项目总数'},
            {field: 'kcCount', title: '勘察项目数'},
            {field: 'fjCount', title: '房建项目数'},
            {field: 'szCount', title: '市政项目数'},
            {field: 'allArea', title: '房建面积（万平方米）'},
            {field: 'allInvest', title: '投资额（万元）'}
        ]];
        configureCom.tableRenderGet(configure.REPORT_KC_SJ_ORG_PERFORMANCE_HTTP, {}, cols, 'dataList', 10, '', 'toolbarOrg');
        //头工具栏事件
        table.on('toolbar(dataList)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            sessionFun.remove(configure.SESSION_PROJECT_LIST_DATA);
            switch (obj.event) {
                case 'add':
                    editItem('新建项目', configure.UNIT_PROJECT_CREATE_HTTP);
                    break;
            }
        });
        //每行操作
        table.on('tool(dataList)', function (obj) {
            var data = obj.data;
            sessionFun.set(configure.SESSION_PROJECT_LIST_DATA, data);
            sessionFun.remove(configure.SESSION_PROJECT_WAIT_LIST_DATA, data);
            if (obj.event === 'detail') {
                editItems('详情', configure.UNIT_PROJECT_DETAIL_HTML);
            } else if (obj.event === 'change') {
                editItem('修改', configure.UNIT_PROJECT_UPDATE_HTTP);
            } else if (obj.event === 'del') {
                //关闭时重新渲染表格当前页
                top.layer.confirm('确认删除？', {title: '提示'}, function (index) {
                    top.layer.close(index);
                    configureCom.postDataAjax(configure.UNIT_ITEM_DELETE_HTTP, {prjId: data.prjId}).then(function (res) {
                        if (res.code == 0) {
                            top.layer.msg('删除成功！');
                            configureCom.tableReload(true);
                        } else {
                            top.layer.alert('删除失败！');
                        }
                    });
                });
            } else if (obj.event === 'push') {
                //项目批转
                top.layer.open({
                    type: 2,
                    title: '项目申报',
                    area: configureCom.Psize1,
                    content: configureCom.nocache(configure.UNIT_PROJECT_APPLY_DETAIL_HTML, iframeId),
                    success: function (layero, index) {
                        top.layer.full(index);
                    },
                    end: function () {
                        configureCom.tableReload();
                    }
                });
            } else if (obj.event === 'applyRecord') {
                top.layer.open({
                    type: 2,
                    title: '查看记录',
                    area: configureCom.Psize1,
                    content: configureCom.nocache(configure.UNIT_PROJECT_APPLY_LIST_HTML, iframeId),
                    end: function () {
                        configureCom.tableReload();
                    }
                });
            }
        });
        //新增或修改字典详情
        function editItem(title, url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize1,
                content: configureCom.nocache(configure.UNIT_PROJECT_DETAIL_HTML),
                btn: ['保存'],
                yes: function (index, layero) {
                    var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对
                    iframeWin.getData().then(function (res) {
                        console.log(res);
                        configureCom.postDataAjax(url, res.result).then(function (res) {
                            console.log(res);
                            top.layer.close(index);
                            top.layer.msg('保存成功！');
                            configureCom.tableReload(true);
                        });
                    });
                },
                success: function (layero, index) {
                    top.layer.full(index);
                }
            });
        }

        //查看详情字典详情
        function editItems(title, url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize1,
                content: configureCom.nocache(configure.UNIT_PROJECT_PROHIBITED_DETAIL_HTML),
                success: function (layero, index) {
                    top.layer.full(index);
                }
            });
        }

        //监听搜索
        configureCom.tableSearch();
    });
</script>
</body>
</html>